package com.ayi.servlet.base; /**
 * @author Ayingzz
 * @create 2021/12/6 20:51
 */

import com.ayi.dao.bookdao.QueryBook;
import com.ayi.dao.userdao.QueryUser;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "UserManageServlet", value = "/UserManageServlet")
public class UserManageServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        /**
         * 用户
         */
            // 准备好所有用户
            request.getSession().setAttribute("usersNotAdmin", new QueryUser().queryUserNotAdmin());

        /**
         * 管理员
         */
            // 准备好所有管理员
            request.getSession().setAttribute("usersIsAdmin", new QueryUser().queryUserIsAdmin());

            // 准备好初始修改状态
            request.getSession().setAttribute("adminIdMap", new QueryUser().queryUserIdForInitEditStatus());

        /**
         *
         */
        request.getRequestDispatcher("userManage.jsp").forward(request, response);
    }
}
